// todo_practice.js
import { editProfile,logout,setupUserProfile} from "./auth.js";
window.editProfile = editProfile;
window.logout = logout;
window.setupUserProfile = setupUserProfile;
// 在页面加载时绑定事件监听器
document.addEventListener('DOMContentLoaded',async function() {
    const urlParams = new URLSearchParams(window.location.search);
    const username = urlParams.get('username');
    await setupUserProfile(username);
    const courses = await getCourses(username);
        if (!courses || courses.length === 0) {
            showNoPractices();
            console.log('没有找到课程');
            return;
        }
    const courseFilter = document.getElementById('courseFilter');
    const submissionFilter = document.getElementById('submissionFilter');
    const judgmentFilter = document.getElementById('judgmentFilter');
    courseFilter.innerHTML = '<option value="all">全部课程</option>';
        if (courseFilter.options.length <= 1) { // 只有"全部课程"选项时
            courseFilter.innerHTML = '<option value="all">全部课程</option>';
            courses.forEach(course =>{
                const option = document.createElement('option');
                option.value = course.course_code;
                option.textContent = course.course_name;
                courseFilter.appendChild(option);
            });
        }
    // 绑定事件监听器
    courseFilter.addEventListener('change', displayPractices);
    submissionFilter.addEventListener('change', displayPractices);
    judgmentFilter.addEventListener('change', displayPractices);
    
    // 初始化显示练习
    displayPractices();
});
async function displayPractices() {
    try {
        // 获取用户信息
        const urlParams = new URLSearchParams(window.location.search);
        const username = urlParams.get('username');
        const userResponse = await fetch(`/user-info?username=${username}`);
        const data = await userResponse.json();
        const userId = data.user_id;
        if (!username) {
            showError('用户名不能为空');
            return;
        }
        //过滤条件
        const selectedCourse = document.getElementById('courseFilter').value;
        const submissionStatus = document.getElementById('submissionFilter').value;
        const judgmentStatus = document.getElementById('judgmentFilter').value;
        // 获取用户选择的课程
        const courses = await getCourses(username);
        if (!courses || courses.length === 0) {
            showNoPractices();
            //console.log('没有找到课程');
            return;
        }

        const practiceList = document.getElementById('practiceList');
        practiceList.innerHTML = '';

        let practiceIds = [];
        for (const course of courses) {
            const practices = await getPracticesByCourse(course.course_code);
            practiceIds = [...new Set([...practiceIds, ...practices.map(p => p.practice_id)])];
        }
        //console.log(practiceIds);
        if (practiceIds.length === 0) {
            showNoPractices();
            return;
        }

        const practices = await Promise.all(
            practiceIds.map(async practiceId => {
                const response = await fetch(`/practice/detail/${practiceId}?userId=${userId}`);
                return await response.json();
            })
        );

        // 新增：提前过滤练习
        const filteredPractices = [];
        for (let i = 0; i < practices.length; i++) {
            const practice = practices[i];
            
            // 1. 应用课程过滤
            if (selectedCourse !== 'all' && practice.course_code !== selectedCourse) {
                continue;
            }
            
            // 2. 获取提交状态并过滤
            const submissionCheckRes = await fetch(`/check-submission?userId=${userId}&practiceId=${practice.practice_id}`);
            const submissionCheckData = await submissionCheckRes.json();
            if (submissionStatus !== 'all') {
                if (submissionStatus === 'submitted' && !submissionCheckData.hasSubmission) continue;
                if (submissionStatus === 'unsubmitted' && submissionCheckData.hasSubmission) continue;
            }
            
            // 3. 获取评阅状态并过滤
            const judgmentCheckRes = await fetch(`/check-judgment?userId=${userId}&practiceId=${practice.practice_id}`);
            const judgmentCheckData = await judgmentCheckRes.json();
            //console.log(judgmentCheckData);
            //console.log(judgmentStatus);
            // 计算实际评阅状态：只有已提交且已评阅才算"已评阅"
    const isJudged = submissionCheckData.hasSubmission && judgmentCheckData.isJudged
    ;
        
        if (judgmentStatus !== 'all') {
            if (judgmentStatus === 'judged' && !isJudged) continue;
            if (judgmentStatus === 'unjudged' && isJudged) continue;
        }
            
            // 通过过滤的练习保留
            filteredPractices.push(practice);
        }
        if (filteredPractices.length === 0) {
                    showFilteredNoPractices();
                    return;
        }
        //console.log(judgmentStatus);
        for (const practice of filteredPractices) {
            const practiceItem = document.createElement('div');
            practiceItem.className = 'practice-card';
            const courseCode = practice.course_code;
            const courseResponse = await fetch(`/get-course/${courseCode}`);
            const course_about_present = await courseResponse.json();
            let totalScore = sessionStorage.getItem(`score_${practice.practice_id}`);
            if (!totalScore) {
                const scoreRes = await fetch(`/api/practice/${practice.practice_id}/total-score`);
                const scoreData = await scoreRes.json();
                totalScore = scoreData.data?.total_score || 0;
                sessionStorage.setItem(`score_${practice.practice_id}`, totalScore);
            }

            // 检查提交状态
            const submissionCheckRes = await fetch(`/check-submission?userId=${userId}&practiceId=${practice.practice_id}`);
            const submissionCheckData = await submissionCheckRes.json();
            //console.log(submissionCheckData);
            let displayScore = '暂未提交';
            if (submissionCheckData.hasSubmission) {
                const calculatedScoreRes = await fetch(`/calculate-total-score?userId=${userId}&practiceId=${practice.practice_id}`);
                const calculatedScoreData = await calculatedScoreRes.json();
                displayScore = `${calculatedScoreData.totalScore}/${totalScore}`;
            }

            // 检查评阅状态
            const judgmentCheckRes = await fetch(`/check-judgment?userId=${userId}&practiceId=${practice.practice_id}`);
            const judgmentCheckData = await judgmentCheckRes.json();
            
            let displayJudgment = (judgmentCheckData.isJudged && submissionCheckData.hasSubmission) ? '已评阅' : '未评阅'; 

            //获取提交时间
            const recentCommitRes = await fetch(`/practice/${practice.practice_id}/user/${userId}/last-submit-time`);
            const recentCommitData = await recentCommitRes.json();
            let recentCommitTime = '';
            if(recentCommitData.success){
                recentCommitTime = new Date(recentCommitData.data).toLocaleString('zh-CN', {
                    year: 'numeric',
                    month: '2-digit',
                    day: '2-digit',
                    hour: '2-digit',
                    minute: '2-digit'
                });
            } else {
                recentCommitTime = '暂未提交';
                displayJudgment = '未评阅';
            }

            // 获取班级排名
            let classRank = '未提交';
            if (submissionCheckData.hasSubmission) {
    // 获取用户班级
    const classResponse = await fetch(`/get-user-class?username=${username}`);
    const classData = await classResponse.json();
    const classCode = classData.class_code;

    if (classCode) {
        // 获取班级成员
        const membersResponse = await fetch(`/get-class-members?classCode=${classCode}`);
        const members = await membersResponse.json();

        // 获取所有已提交成员的分数
        const submittedMembers = [];
        for (const member of members) {
            const memberSubmissionCheckRes = await fetch(`/check-submission?userId=${member.user_id}&practiceId=${practice.practice_id}`);
            const memberSubmissionCheckData = await memberSubmissionCheckRes.json();
            if (memberSubmissionCheckData.hasSubmission) {
                // 获取成员分数
                const memberScoreRes = await fetch(`/calculate-total-score?userId=${member.user_id}&practiceId=${practice.practice_id}`);
                const memberScoreData = await memberScoreRes.json();
                submittedMembers.push({ 
                    userId: member.user_id, 
                    score: memberScoreData.totalScore 
                });
            }
        }

        // 如果没有其他同学提交（只有当前用户提交），则排名为1
        if (submittedMembers.length === 0) {
            classRank = 1;
        } else {
            // 按分数降序排序
            submittedMembers.sort((a, b) => b.score - a.score);
            
            // 计算排名（处理并列情况）
            const rankData = [];
            let currentRank = 1;
            let previousScore = submittedMembers[0].score;
            let sameScoreCount = 1;
            
            for (let i = 0; i < submittedMembers.length; i++) {
                const member = submittedMembers[i];
                
                if (member.score < previousScore) {
                    // 分数降低，更新排名
                    currentRank += sameScoreCount;
                    sameScoreCount = 1;
                    previousScore = member.score;
                } else {
                    // 分数相同，保持排名
                    sameScoreCount++;
                }
                
                rankData.push({
                    userId: member.userId,
                    score: member.score,
                    rank: currentRank
                });
            }
            
            // 查找目标用户的排名
            const targetUserRank = rankData.find(r => r.userId === userId);
            if (targetUserRank) {
                classRank = targetUserRank.rank;
            } else {
                classRank = '未找到排名';
            }
        }
    } else {
        classRank = '未加入班级';
    }
            }
            practiceItem.innerHTML = `
    <div class="flex flex-col space-y-3 relative overflow-hidden">
        <!-- 渐变背景层 -->
        <!-- 内容层 -->
        <div class="relative z-10">
            <div class="flex items-center justify-between">
                <div class="flex items-center space-x-2">
                    <i class="fa-solid fa-clipboard-check text-primary text-xl"></i>
                    <h3 class="text-lg font-bold text-gray-800">${escapeHTML(practice.practice_name)}</h3>
                </div>
                <span class="px-3 py-1 rounded-full text-xs font-medium ${getDeadlineStatus(practice.deadline)} bg-white/90 backdrop-blur-sm border border-gray-200/80">
                    ${formatDeadlineStatus(practice.deadline)}
                </span>
            </div>
            
            <div class="bg-white/80 backdrop-blur-sm p-4 rounded-lg border border-gray-200/80 mt-3 shadow-sm">
                <div class="flex items-center space-x-2 mb-3">
                    <i class="fa-solid fa-book text-primary"></i>
                    <p class="text-gray-600">所属课程：${course_about_present.course_name}</p>
                </div>
                
                <div class="grid grid-cols-2 md:grid-cols-5 gap-4">
                    <div class="flex flex-col space-y-1">
                        <label class="text-xs text-gray-500">
                            <i class="fa-solid fa-clock-o mr-1"></i> 截止时间
                        </label>
                        <time class="text-gray-800 font-medium">${formatDateTime(practice.deadline)}</time>
                    </div>
                    
                    <div class="flex flex-col space-y-1">
                        <label class="text-xs text-gray-500">
                            <i class="fa-solid fa-paper-plane mr-1"></i> 剩余提交
                        </label>
                        <span class="text-gray-800 font-medium ${practice.remaining_submit_times <= 1 ? 'text-red-500' : 'text-green-600'}">
                            ${practice.remaining_submit_times}次
                        </span>
                    </div>
                    
                    <div class="flex flex-col space-y-1">
                        <label class="text-xs text-gray-500">
                            <i class="fa-solid fa-star mr-1"></i> 总分
                        </label>
                        <span class="text-gray-800 font-medium">${totalScore}</span>
                    </div>
                    
                    <div class="flex flex-col space-y-1">
                        <label class="text-xs text-gray-500">
                            <i class="fa-solid fa-trophy mr-1"></i> 得分
                        </label>
                        <span class="text-gray-800 font-medium ${getScoreStatus(displayScore)}">
                            ${displayScore}
                        </span>
                    </div>
                    
                    <div class="flex flex-col space-y-1">
                        <label class="text-xs text-gray-500">
                            <i class="fa-solid fa-check-circle mr-1"></i> 评阅状态
                        </label>
                        <span class="text-gray-800 font-medium ${judgmentCheckData.isJudged && recentCommitData.success ? 'text-green-600' : 'text-yellow-500'}">
                            ${displayJudgment}
                        </span>
                    </div>

                    <div class="flex flex-col space-y-1">
                        <label class="text-xs text-gray-500">
                            <i class="fa-solid fa-ranking-star mr-1"></i> 班级排名
                        </label>
                        <span class="text-gray-800 font-medium">
                            ${classRank}
                        </span>
                    </div>
                </div>
                
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex items-center space-x-2">
                        <i class="fa-solid fa-history text-primary"></i>
                        <label class="text-xs text-gray-500">最近提交时间</label>
                    </div>
                    <p class="text-gray-800 font-medium mt-1">${recentCommitTime}</p>
                </div>
            </div>
        </div>
    </div>
`;
            if (practice.remaining_submit_times > 0) {
                practiceItem.innerHTML += `
                <div class="flex justify-center space-x-4">
        <button class="view-answer-btn px-4 py-2 bg-primary text-white rounded-lg btn-hover">查看答案</button>
        <button class="recent-commit-btn px-4 py-2 bg-primary text-white rounded-lg btn-hover">最近提交</button>
        <button class="do-practice-btn px-4 py-2 bg-primary text-white rounded-lg btn-hover">做练习</button>
                </div>
                `;
                const doPracticeBtn = practiceItem.querySelector('.do-practice-btn');
                doPracticeBtn.addEventListener('click', async () => {
                    const practiceDetailResponse = await fetch(`/practice/detail/${practice.practice_id}?userId=${userId}`);    
                    const practiceDetail = await practiceDetailResponse.json();    
                    const deadline = new Date(practiceDetail.deadline);    
                    const now = new Date();
                    if (now > deadline) {        
                        alert('已超过练习截止时间，无法做练习。');        
                        return;
                    }
                    window.location.href = `/do-practice.html?practiceId=${practice.practice_id}&username=${username}`;
                });
            } else {
                practiceItem.innerHTML += `
                <div class="flex justify-center space-x-4">
        <button class="view-answer-btn px-4 py-2 bg-primary text-white rounded-lg btn-hover">查看答案</button>
        <button class="recent-commit-btn px-4 py-2 bg-primary text-white rounded-lg btn-hover">最近提交</button>
        <button class="px-4 py-2 bg-gray-200 rounded-lg text-gray-600" disabled>提交次数已耗尽</button>
    </div>
                `;
            }
            const viewAnswerBtn = practiceItem.querySelector('.view-answer-btn');        
            viewAnswerBtn.addEventListener('click', async () => {                
            if (!submissionCheckData.hasSubmission) {                    
                alert('你还没有提交过此练习，无法查看答案');                    
                return;
            }                
            if (practice.remaining_submit_times > 0) {                    
                // 显示模态框                                      
                const modal = document.getElementById('viewAnswerModal');
                modal.style.opacity = '1';
                modal.style.pointerEvents = 'auto';
                // 确定按钮点击事件                    
                const confirmViewAnswerBtn = document.getElementById('confirmViewAnswerBtn');                    
                confirmViewAnswerBtn.addEventListener('click', async () => {                        
                try {                            
                // 调用接口清零剩余提交次数                            
                    await fetch(`/clear-remaining-submit-times?userId=${userId}&practiceId=${practice.practice_id}`, {                                
                    method: 'POST',                                
                    headers: {                                    
                        'Content-Type': 'application/json'
                    },                                
                    body: JSON.stringify({ userId, practiceId: practice.practice_id })
                });
                // 隐藏模态框                            
                modal.style.opacity = '0';
                modal.style.pointerEvents = 'none';
                // 跳转到查看答案页面                            
                    window.location.href = `/view-answer.html?username=${username}&practiceId=${practice.practice_id}`;
                } catch (error) {                            
                    console.error('清零剩余提交次数失败:', error);                            
                    alert('清零剩余提交次数失败，请稍后重试');
                }
                });
                // 取消按钮点击事件                    
                const cancelViewAnswerBtn = document.getElementById('cancelViewAnswerBtn');                    
                cancelViewAnswerBtn.addEventListener('click', () => {                        
                // 隐藏模态框                        
                modal.style.opacity = '0';
                modal.style.pointerEvents = 'none';
                });
                // 关闭模态框按钮点击事件                    
                const closeViewAnswerModalBtn = document.getElementById('closeViewAnswerModalBtn');                    
                closeViewAnswerModalBtn.addEventListener('click', () => {                        
                // 隐藏模态框                        
                modal.style.opacity = '0';
                modal.style.pointerEvents = 'none';
                });
                } else {                    
                    window.location.href = `/view-answer.html?username=${username}&practiceId=${practice.practice_id}`;
                }
            });
            const recentCommitBtn = practiceItem.querySelector('.recent-commit-btn');            
            recentCommitBtn.addEventListener('click', async () => {                
                if (!submissionCheckData.hasSubmission) {                    
                    alert('你还没有提交过此练习，无法查看最近提交记录。');                    
                    return;
                }                
                window.location.href = `/recent-commit.html?username=${username}&practiceId=${practice.practice_id}`;
            });            
            practiceList.appendChild(practiceItem);
        }
        // 生成报告按钮部分
        document.getElementById('generateReportBtn').addEventListener('click', async () => {
            const generateBtn = document.getElementById('generateReportBtn');
            const practiceCards = document.querySelectorAll('.practice-card');
            if (practiceCards.length === 0) {
                alert('当前没有可生成的练习，请检查筛选条件。');
                return;
            }
            try {
                
                // 显示加载提示
                generateBtn.innerHTML = `
                    <i class="fa-solid fa-spinner animate-spin mr-2"></i> 正在生成截图...
                `;
                generateBtn.disabled = true;
                
                // 获取当前时间用于文件名
                const now = new Date();
                const timestamp = `${now.getFullYear()}${(now.getMonth()+1).toString().padStart(2, '0')}${now.getDate().toString().padStart(2, '0')}_${now.getHours().toString().padStart(2, '0')}${now.getMinutes().toString().padStart(2, '0')}`;
                
                // 获取用户名用于文件名
                const urlParams = new URLSearchParams(window.location.search);
                const username = urlParams.get('username');
                
                // 截取练习列表区域
                const element = document.getElementById('practiceList');

                // 使用html2canvas生成图片
                const canvas = await html2canvas(element, {
                    scale: 2, // 提高分辨率
                    logging: false,
                    useCORS: true,
                    allowTaint: true,
                    scrollY: -window.scrollY // 防止滚动条影响
                });
                // 创建下载链接
                const link = document.createElement('a');
                link.download = `${username}_练习列表_${timestamp}.png`;
                link.href = canvas.toDataURL('image/png');
                link.click();
            } catch (error) {
                console.error('生成截图失败:', error);
                alert('生成截图失败，请稍后重试');
            } finally {
                // 恢复按钮状态
                generateBtn.innerHTML = '<i class="fa-solid fa-image mr-2"></i> 导出练习截图(PNG)';
                generateBtn.disabled = false;

            }
        });
    } catch (error) {
        //console.error = originalConsoleError;
        console.log(`加载失败：${error.message}`);
    }
}

function showError(message) {
    const practiceList = document.getElementById('practiceList');
    practiceList.innerHTML = `<p class="error">${message}</p>`;
}

// 新增：显示过滤后的空状态
function showFilteredNoPractices(
) {
    const practiceList = document.getElementById('practiceList'
);
    
    // 获取当前过滤条件
    const selectedCourse = document.getElementById('courseFilter').value;
    const submissionStatus = document.getElementById('submissionFilter').value;
    const judgmentStatus = document.getElementById('judgmentFilter').value;
    //console.log(`当前筛选条件：课程=${selectedCourse}, 提交状态=${submissionStatus}, 评阅状态=${judgmentStatus}`);
    // 生成条件描述文本
    let conditions = [];
    if (selectedCourse !== 'all') {
        const courseName = document.querySelector(`#courseFilter option[value="${selectedCourse}"]`).textContent;
        conditions.push(`课程: ${courseName}`);
    }
    if (submissionStatus !== 'all') {
        conditions.push(`提交状态: ${submissionStatus === 'submitted' ? '已提交' : '未提交'}`);
    }
    if (judgmentStatus !== 'all') {
        conditions.push(`评阅状态: ${judgmentStatus === 'judged' ? '已评阅' : '未评阅'}`);
    }
    
    const conditionText = conditions.length > 0  ? `（当前条件: ${conditions.join(',')}）` : '';
    
    // 创建空状态UI
    practiceList.
innerHTML = 
`
        <div class="empty-state text-center py-12">
            <div class="mx-auto w-24 h-24 rounded-full bg-gray-100 flex items-center justify-center mb-6">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
                </svg>
            </div>
            <h3 class="text-xl font-medium text-gray-700 mb-2">未找到符合条件的练习</h3>
            <p class="text-gray-500 mb-6">请尝试调整筛选条件
${conditionText}
</p>
            <button id="resetFiltersBtn" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary-dark transition-colors">
                重置所有筛选条件
            </button>
        </div>
    `
;
    
    // 添加重置按钮事件
    document.getElementById('resetFiltersBtn').addEventListener('click', () =>{
        document.getElementById('courseFilter').value = 'all';
        document.getElementById('submissionFilter').value = 'all';
        document.getElementById('judgmentFilter').value = 'all';
        displayPractices();
    });
}

// 修改原showNoPractices函数
function showNoPractices() {
    const practiceList = document.getElementById('practiceList');
    practiceList.innerHTML = 
`
        <div class="empty-state text-center py-12">
            <div class="mx-auto w-24 h-24 rounded-full bg-gray-100 flex items-center justify-center mb-6">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
                </svg>
            </div>
            <h3 class="text-xl font-medium text-gray-700 mb-2">当前没有可用练习</h3>
            <p class="text-gray-500">请检查课程安排或联系老师获取更多信息</p>
        </div>
    `
;
}


function escapeHTML(str) {
    if (typeof str !== 'string') return str;
    return str.replace(/[&<>"']/g, function (match) {
        switch (match) {
            case '&':
                return '&amp;';
            case '<':
                return '&lt;';
            case '>':
                return '&gt;';
            case '"':
                return '&quot;';
            case "'":
                return '&#039;';
        }
    });
}

function formatDateTime(dateTime) {
    return new Date(dateTime).toLocaleString();
}

// 获取用户已选课程
async function getCourses(username) {
    const response = await fetch(`/get-selected-courses?username=${username}`);
    const courses = await response.json();
    return courses;
}

// 新增获取课程对应的练习的接口
async function getPracticesByCourse(courseCode) {
    const response = await fetch(`/practice/course/${courseCode}`);
    return await response.json();
}


document.getElementById('goBackBtn').addEventListener('click', () => {
    const urlParams = new URLSearchParams(window.location.search);
    const username = urlParams.get('username');
    window.location.href = 'success.html?username=' + username;
});

document.addEventListener('DOMContentLoaded', function() {
    // 获取"返回"链接元素
    const backLink = document.querySelector('ul.flex li:first-child a');
    if (backLink) {
        // 添加点击事件监听器
        backLink.addEventListener('click', function(event) {
            event.preventDefault(); 
            window.location.href ='success.html'+window.location.search;
        });
    }
});

// 辅助函数：根据截止时间返回状态样式
function getDeadlineStatus(deadline) {    
    const now = new Date();    
    const deadlineDate = new Date(deadline);    
    const diff = deadlineDate - now;        
    if (diff < 0) {        
    return 'bg-red-100 text-red-800';
        } else if (diff < 24 * 60 * 60 * 1000) {        
    return 'bg-yellow-100 text-yellow-800';
        } else {        
    return 'bg-green-100 text-green-800';
        }
    }
    // 辅助函数：根据截止时间返回状态文本
    function formatDeadlineStatus(deadline) {    
    const now = new Date();    
    const deadlineDate = new Date(deadline);        
    if (now > deadlineDate) {        
    return '已截止';
        }        
    const diffHours = Math.floor((deadlineDate - now) / (1000 * 60 * 60));    
    if (diffHours < 24) {        
    return '即将截止';
        }        
    return '进行中';
    }
    // 辅助函数：根据得分情况返回样式
    function getScoreStatus(scoreText) {    
    if (scoreText === '暂未提交') return 'text-gray-500';        
    const [current, total] = scoreText.split('/').map(Number);    
    const percentage = (current / total) * 100;        
    if (percentage >= 80) return 'text-green-600';    
    if (percentage >= 60) return 'text-yellow-600';    
    return 'text-red-500';
    }


  export{
      displayPractices,
      showError,
      showFilteredNoPractices,
      showNoPractices,
      escapeHTML,
      formatDateTime,
      getCourses,
      getPracticesByCourse,
      getDeadlineStatus,
      formatDeadlineStatus,
      getScoreStatus,
  }
          
          
   